package cn.zhaoyan.servlet;

import cn.zhaoyan.bean.Customer;
import cn.zhaoyan.service.CustomerService;
import cn.zhaoyan.serviceimpl.CustomerServiceipml;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(urlPatterns = "/CustomerServlet")
public class CustomerServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        request.setCharacterEncoding("utf-8");
        CustomerService customerServiceipml = new CustomerServiceipml();
        List<Customer> list = customerServiceipml.queryService();
        request.setAttribute("list",list);
        request.getRequestDispatcher("hello.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}